<style>
    label{ display:inline-block;width: 10%}
</style>
<script src="/statics/js/jquery.select.js"></script>
<div class="container-fluid" style="padding: 20px 10px 0px 10px">

    <div class="row-fluid">

        <div class="well">

            <div id="myTabContent" class="tab-content">

                <div class="tab-pane active in" id="home">

                    <ul class="nav nav-tabs">

                        <li class="active"><b>接收主体信息</b></li>
                    </ul>
                    <form id="formid" action="/take/out_take_drug" method="post" style="width: 100%;text-align: left">
                        <input type="hidden" name="take_orderid" value="<?=I('get.order_id')?>">
                        <input type="hidden" name="takedrug_id" value="<?=I('get.takedrug_id')?>">
                        <input type="hidden" name="submit" value="1">
                        <p><label>领用单号 : </label>
                            <input type="text" id="getGroupList" name="income_orderid">
                            <!--<select name="income_orderid" id="income_orderid">-->
                                <!--<option value="">请选择</option>-->
                                <!--<?php if($groupDate){foreach($groupDate as $k=>$v){?>-->
                                <!--<option value="<?=$v?>"><?=$v?></option>-->
                                <!--<?php }}?>-->
                            <!--</select>-->
                            <label style="padding-left: 28px;">接收护士 : </label>
                            <input type="text" name="get_nurse" placeholder="接收护士" value="">
                        </p>
                        <p><label>接收课别 : </label>

                            <input type="text" name="use_class" readonly placeholder="接收课别" value="">
                        <label style="padding-left: 28px;">组会地点 : </label>

                        <input type="text" name="group_place" readonly placeholder="组会地点" value="">
                        </p>
                        <p><label>组会医生 : </label>

                            <input type="text" name="group_doctor" readonly placeholder="组会医生" value="">
                            <label style="padding-left: 28px;">组会日期 : </label>

                            <input type="text" name="group_date" readonly placeholder="组会日期" value="">
                        </p>

                        <ul class="nav nav-tabs">

                            <li class="active"><b>药品信息</b></li>
                        </ul>
                        <p><label>转出数量 : </label>

                            <input type="text" name="out_num" value="">

                        </p>

                        <p>
                            <label>备注 : </label>
                            <textarea style="display:inline; width: 529px; height: 50px;" name="remark"></textarea>

                        </p>


                        <div class="btn-toolbar">
                            <div class="btn-group" style="margin:30px 0 10px 280px;">
                                <input type="submit" name="" value="保存" class="btn btn-primary">
                            </div>
                        </div>
                    </form>

                </div>

            </div>

        </div>

    </div>

    <input type="hidden" id="hidden_order_id" value="<?=$order_id?>">
    <script>
        $(function(){
            $.ajax({
                url: '/take/getGroupList',
                type: 'POST',
                dataType: 'json',
                data: {order_id: $('#hidden_order_id').val()},
            })
            .done(function(data) {
                if(data.code == '0'){
                    var datas = data.data;
                    $.selectSuggest('getGroupList',datas,getGroupInfo);
                }else{
                    alert(data.msg);
                }
            })
            .fail(function() {
                console.log("error");
            })

        $('#btn-save').click(function(){
            $('#formid').submit();
        });

            function getGroupInfo(){
                var val = this.id;
                $.ajax({
                    url: '/take/getTakeInfo',
                    type: 'POST',
                    dataType: 'json',
                    data: {orderid: val},
                })
                .done(function(data) {
                    if(data.code == '0'){
                        $('input[name=use_class]').val(data.data.use_class);
                        $('input[name=group_place]').val(data.data.group_place);
                        $('input[name=group_doctor]').val(data.data.group_doctor);
                        $('input[name=group_date]').val(data.data.group_date);
                    }else{
                        alert(data.msg);
                    }
                })
                .fail(function() {
                    console.log("error");
                })
            }

            $('#getGroupList').on('keyup',function(){
                console.log('123');
                var lenth = $(this).val().length;
                if(lenth == 13){
                    $.ajax({
                        url: '/take/getTakeInfo',
                        type: 'POST',
                        dataType: 'json',
                        data: {orderid: $(this).val()},
                    })
                    .done(function(data) {
                        if(data.code == '0'){
                            $('input[name=use_class]').val(data.data.use_class);
                            $('input[name=group_place]').val(data.data.group_place);
                            $('input[name=group_doctor]').val(data.data.group_doctor);
                            $('input[name=group_date]').val(data.data.group_date);
                        }else{
                            alert(data.msg);
                        }
                    })
                    .fail(function() {
                        console.log("error");
                    })
                }
            })





        })

    </script>